package beans.thread.lululu;

/**
 * 这個方法中断壹個线程，如果线程在睡觉或者正在加入另壹個线程，方法就会抛出壹個InterruptedException<br/>
 * 如果线程在睡觉或者加入另壹個线程，线程的中断状态会被清除
 * 
 * @author Jert
 * 
 */
public class MainInterruptThread
{
	public static void main(String[] args)
	{

		Thread thread1 = new Thread(new WaitRunnable());
		thread1.start();
		try
		{
			Thread.sleep(1000);
		}
		catch (InterruptedException e)
		{
			e.printStackTrace();
		}
		thread1.interrupt();

	}

	private static class WaitRunnable implements Runnable
	{
		@Override
		public void run()
		{
			System.out.println("Current time millis : " + System.currentTimeMillis());
			try
			{
				Thread.sleep(5000);
			}
			catch (InterruptedException e)
			{
				System.out.println("The thread has been interrupted");
				System.out.println("The thread is interrupted : " + Thread.currentThread().isInterrupted());
			}
			System.out.println("Current time millis : " + System.currentTimeMillis());
		}
	}

}
